package com.ruicar.afs.cloud.bizcommon.voucher.controller;

import com.ruicar.afs.cloud.bizcommon.voucher.mapper.VoucherAmtMapper;
import com.ruicar.afs.cloud.common.core.util.IResponse;
import com.ruicar.afs.cloud.common.modules.dto.voucher.VoucherBusinessDataDto;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author infinity
 * @version 1.0
 * @date 2020/7/10 21:23
 */
@AllArgsConstructor
@Slf4j
@RestController
@RequestMapping(value = "/voucher")
public class VoucherController {
    private final VoucherAmtMapper voucherAmtMapper;

    @PostMapping("/get")
    public IResponse getVouncherInfo(@RequestBody VoucherBusinessDataDto dto) {
        dto.getVoucherKeyToQLExpressDtos().forEach(entryInfoDto -> {
                    entryInfoDto.setAmt(voucherAmtMapper.getAmt(entryInfoDto.getQlExpress()));
                }
        );
        return IResponse.success(dto);
    }
}
